import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],

  server: {
    host: "0.0.0.0", //解决控制台 ：Network: use --host to expose
    port: 8080,
    hmr: true,
    open: true,
    proxy: {
      "/api": {
        target: "http://localhost:8080",
        changeOrigin: true,
      },
    },
  },

  resolve: {
    // 修正这里，加上冒号
    alias: [
      {
        find: "@", // 别名
        replacement: path.resolve(__dirname, "src"), // 替换为 src 目录的绝对路径
      },
    ],
  },
});
